home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / CursorDevices.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  8.0 KB  |  246 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        CursorDevices.h
  3.  
  4.      Contains:    Cursor Devices (mouse/trackball/etc) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1993-1997 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __CURSORDEVICES__
  19. #define __CURSORDEVICES__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27.  
  28.  
  29.  
  30. #if PRAGMA_ONCE
  31. #pragma once
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. #if PRAGMA_IMPORT
  39. #pragma import on
  40. #endif
  41.  
  42. #if PRAGMA_STRUCT_ALIGN
  43.     #pragma options align=mac68k
  44. #elif PRAGMA_STRUCT_PACKPUSH
  45.     #pragma pack(push, 2)
  46. #elif PRAGMA_STRUCT_PACK
  47.     #pragma pack(2)
  48. #endif
  49.  
  50. /*
  51.                         * * *  I M P O R T A N T  * * * 
  52.  
  53.             You will need CursorDevicesGlue.o to use CDM from PowerPC
  54.  
  55.  
  56.     In order to use the Cursor Devices Manager (CDM) on PowerPC systems, you must 
  57.     link with the file CursorDevicesGlue.o and InterfaceLib 1.1.3.  This is necessary
  58.     because the original MixedMode transition code for CDM in InterfaceLib in ROM
  59.     was wrong.  The code in CursorDevicesGlue.o will check to see if the ROM has
  60.     been fixed and calls through to it if so.  If it detects that the ROM has not
  61.     been fixed, it uses its own implementation of the CDM MixedMode transition 
  62.     routines. 
  63.     
  64. */
  65.  
  66. typedef short                             ButtonOpcode;
  67. /* ButtonOpcodes */
  68.  
  69. enum {
  70.     kButtonNoOp                    = 0,                            /* No action for this button */
  71.     kButtonSingleClick            = 1,                            /* Normal mouse button */
  72.     kButtonDoubleClick            = 2,                            /* Click-release-click when pressed */
  73.     kButtonClickLock            = 3                                /* Click on press, release on next press */
  74. };
  75.  
  76.  
  77. enum {
  78.     kButtonCustom                = 6                                /* Custom behavior, data = CursorDeviceCustomButtonUPP */
  79. };
  80.  
  81. /* Device Classes */
  82.  
  83. enum {
  84.     kDeviceClassAbsolute        = 0,                            /* a flat-response device */
  85.     kDeviceClassMouse            = 1,                            /* mechanical or optical mouse */
  86.     kDeviceClassTrackball        = 2,                            /* trackball */
  87.     kDeviceClassTrackPad        = 3
  88. };
  89.  
  90.  
  91. enum {
  92.     kDeviceClass3D                = 6                                /* a 3D pointing device */
  93. };
  94.  
  95. /* Structures used in Cursor Device Manager calls */
  96. struct CursorData {
  97.     struct CursorData *                nextCursorData;                /* next in global list */
  98.     Ptr                             displayInfo;                /* unused (reserved for future) */
  99.     Fixed                             whereX;                        /* horizontal position */
  100.     Fixed                             whereY;                        /* vertical position */
  101.     Point                             where;                        /* the pixel position */
  102.     Boolean                         isAbs;                        /* has been stuffed with absolute coords */
  103.     UInt8                             buttonCount;                /* number of buttons currently pressed */
  104.     long                             screenRes;                    /* pixels per inch on the current display */
  105.     short                             privateFields[22];            /* fields use internally by CDM */
  106. };
  107. typedef struct CursorData CursorData;
  108.  
  109. typedef CursorData *                    CursorDataPtr;
  110. struct CursorDevice {
  111.     struct CursorDevice *            nextCursorDevice;            /* pointer to next record in linked list */
  112.     CursorData *                    whichCursor;                /* pointer to data for target cursor */
  113.     long                             refCon;                        /* application-defined */
  114.     long                             unused;                        /* reserved for future */
  115.     OSType                             devID;                        /* device identifier (from ADB reg 1) */
  116.     Fixed                             resolution;                    /* units/inch (orig. from ADB reg 1) */
  117.     UInt8                             devClass;                    /* device class (from ADB reg 1) */
  118.     UInt8                             cntButtons;                    /* number of buttons (from ADB reg 1) */
  119.     UInt8                             filler1;                    /* reserved for future */
  120.     UInt8                             buttons;                    /* state of all buttons */
  121.     UInt8                             buttonOp[8];                /* action performed per button */
  122.     unsigned long                     buttonTicks[8];                /* ticks when button last went up (for debounce) */
  123.     long                             buttonData[8];                /* data for the button operation */
  124.     unsigned long                     doubleClickTime;            /* device-specific double click speed */
  125.     Fixed                             acceleration;                /* current acceleration */
  126.     short                             privateFields[15];            /* fields used internally to CDM */
  127. };
  128. typedef struct CursorDevice CursorDevice;
  129.  
  130. typedef CursorDevice *                    CursorDevicePtr;
  131. /* for use with CursorDeviceButtonOp when opcode = kButtonCustom */
  132. typedef CALLBACK_API( void , CursorDeviceCustomButtonProcPtr )(CursorDevicePtr ourDevice, short button);
  133. /*
  134.     WARNING: CursorDeviceCustomButtonProcPtr uses register based parameters under classic 68k
  135.              and cannot be written in a high-level language without 
  136.              the help of mixed mode or assembly glue.
  137. */
  138. typedef REGISTER_UPP_TYPE(CursorDeviceCustomButtonProcPtr)         CursorDeviceCustomButtonUPP;
  139. enum { uppCursorDeviceCustomButtonProcInfo = 0x000ED802 };         /* register no_return_value Func(4_bytes:A2, 2_bytes:D3) */
  140. #define NewCursorDeviceCustomButtonProc(userRoutine)             (CursorDeviceCustomButtonUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppCursorDeviceCustomButtonProcInfo, GetCurrentArchitecture())
  141. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  142.     /* CallCursorDeviceCustomButtonProc can't be called from classic 68k without glue code */
  143. #else
  144.     #define CallCursorDeviceCustomButtonProc(userRoutine, ourDevice, button)  CALL_TWO_PARAMETER_UPP((userRoutine), uppCursorDeviceCustomButtonProcInfo, (ourDevice), (button))
  145. #endif
  146. EXTERN_API( OSErr )
  147. CursorDeviceMove                (CursorDevicePtr         ourDevice,
  148.                                  long                     deltaX,
  149.                                  long                     deltaY)                                TWOWORDINLINE(0x7000, 0xAADB);
  150.  
  151. EXTERN_API( OSErr )
  152. CursorDeviceMoveTo                (CursorDevicePtr         ourDevice,
  153.                                  long                     absX,
  154.                                  long                     absY)                                TWOWORDINLINE(0x7001, 0xAADB);
  155.  
  156. EXTERN_API( OSErr )
  157. CursorDeviceFlush                (CursorDevicePtr         ourDevice)                            TWOWORDINLINE(0x7002, 0xAADB);
  158.  
  159. EXTERN_API( OSErr )
  160. CursorDeviceButtons                (CursorDevicePtr         ourDevice,
  161.                                  short                     buttons)                            TWOWORDINLINE(0x7003, 0xAADB);
  162.  
  163. EXTERN_API( OSErr )
  164. CursorDeviceButtonDown            (CursorDevicePtr         ourDevice)                            TWOWORDINLINE(0x7004, 0xAADB);
  165.  
  166. EXTERN_API( OSErr )
  167. CursorDeviceButtonUp            (CursorDevicePtr         ourDevice)                            TWOWORDINLINE(0x7005, 0xAADB);
  168.  
  169. EXTERN_API( OSErr )
  170. CursorDeviceButtonOp            (CursorDevicePtr         ourDevice,
  171.                                  short                     buttonNumber,
  172.                                  ButtonOpcode             opcode,
  173.                                  long                     data)                                TWOWORDINLINE(0x7006, 0xAADB);
  174.  
  175. EXTERN_API( OSErr )
  176. CursorDeviceSetButtons            (CursorDevicePtr         ourDevice,
  177.                                  short                     numberOfButtons)                    TWOWORDINLINE(0x7007, 0xAADB);
  178.  
  179. EXTERN_API( OSErr )
  180. CursorDeviceSetAcceleration        (CursorDevicePtr         ourDevice,
  181.                                  Fixed                     acceleration)                        TWOWORDINLINE(0x7008, 0xAADB);
  182.  
  183. EXTERN_API( OSErr )
  184. CursorDeviceDoubleTime            (CursorDevicePtr         ourDevice,
  185.                                  long                     durationTicks)                        TWOWORDINLINE(0x7009, 0xAADB);
  186.  
  187. EXTERN_API( OSErr )
  188. CursorDeviceUnitsPerInch        (CursorDevicePtr         ourDevice,
  189.                                  Fixed                     resolution)                            TWOWORDINLINE(0x700A, 0xAADB);
  190.  
  191. EXTERN_API( OSErr )
  192. CursorDeviceNextDevice            (CursorDevicePtr *        ourDevice)                            TWOWORDINLINE(0x700B, 0xAADB);
  193.  
  194. EXTERN_API( OSErr )
  195. CursorDeviceNewDevice            (CursorDevicePtr *        ourDevice)                            TWOWORDINLINE(0x700C, 0xAADB);
  196.  
  197. EXTERN_API( OSErr )
  198. CursorDeviceDisposeDevice        (CursorDevicePtr         ourDevice)                            TWOWORDINLINE(0x700D, 0xAADB);
  199.  
  200.  
  201.  
  202.  
  203. /*
  204.                        * * *  W A R N I N G  * * * 
  205.                 
  206.     The routines CrsrDevMoveTo and CrsrDevNextDevice are no longer needed.
  207.     They were added as a work around until the glue code CursorDevicesGlue.o
  208.     was created.  Please use the functions CursorDeviceMoveTo and
  209.     CursorDeviceNextDevice instead.
  210.  
  211. */
  212. #if OLDROUTINENAMES
  213. EXTERN_API( OSErr )
  214. CrsrDevMoveTo                    (CursorDevicePtr         ourDevice,
  215.                                  long                     absX,
  216.                                  long                     absY)                                TWOWORDINLINE(0x7001, 0xAADB);
  217.  
  218. EXTERN_API( OSErr )
  219. CrsrDevNextDevice                (CursorDevicePtr *        ourDevice)                            TWOWORDINLINE(0x700B, 0xAADB);
  220.  
  221. #endif  /* OLDROUTINENAMES */
  222.  
  223.  
  224.  
  225.  
  226. #if PRAGMA_STRUCT_ALIGN
  227.     #pragma options align=reset
  228. #elif PRAGMA_STRUCT_PACKPUSH
  229.     #pragma pack(pop)
  230. #elif PRAGMA_STRUCT_PACK
  231.     #pragma pack()
  232. #endif
  233.  
  234. #ifdef PRAGMA_IMPORT_OFF
  235. #pragma import off
  236. #elif PRAGMA_IMPORT
  237. #pragma import reset
  238. #endif
  239.  
  240. #ifdef __cplusplus
  241. }
  242. #endif
  243.  
  244. #endif /* __CURSORDEVICES__ */
  245.  
  246.